package com.cinema.model;

import java.util.Objects;

/**
 * 座位类
 * 
 * @author Cinema Management System
 * @version 1.0.0
 */
public class Seat {
    
    /**
     * 座位ID
     */
    private String seatId;
    
    /**
     * 排数
     */
    private int row;
    
    /**
     * 列数
     */
    private int column;
    
    /**
     * 放映厅ID
     */
    private String hallId;
    
    /**
     * 是否可用
     */
    private boolean available;
    
    /**
     * 座位状态
     */
    private SeatStatus status;
    
    /**
     * 默认构造函数
     */
    public Seat() {
        this.available = true;
        this.status = SeatStatus.AVAILABLE;
    }
    
    /**
     * 构造函数
     * 
     * @param row 排数
     * @param column 列数
     * @param hallId 放映厅ID
     */
    public Seat(int row, int column, String hallId) {
        this();
        this.row = row;
        this.column = column;
        this.hallId = hallId;
        this.seatId = generateSeatId();
    }
    
    /**
     * 生成座位ID
     * 
     * @return 座位ID
     */
    private String generateSeatId() {
        return hallId + "_" + String.format("%02d", row) + "_" + String.format("%02d", column);
    }
    
    /**
     * 占用座位
     */
    public void occupy() {
        this.available = false;
        this.status = SeatStatus.OCCUPIED;
    }
    
    /**
     * 释放座位
     */
    public void release() {
        this.available = true;
        this.status = SeatStatus.AVAILABLE;
    }
    
    /**
     * 预订座位
     */
    public void reserve() {
        this.available = false;
        this.status = SeatStatus.RESERVED;
    }
    
    // Getter和Setter方法
    public String getSeatId() {
        return seatId;
    }
    
    public void setSeatId(String seatId) {
        this.seatId = seatId;
    }
    
    public int getRow() {
        return row;
    }
    
    public void setRow(int row) {
        this.row = row;
    }
    
    public int getColumn() {
        return column;
    }
    
    public void setColumn(int column) {
        this.column = column;
    }
    
    public String getHallId() {
        return hallId;
    }
    
    public void setHallId(String hallId) {
        this.hallId = hallId;
    }
    
    public boolean isAvailable() {
        return available;
    }
    
    public void setAvailable(boolean available) {
        this.available = available;
    }
    
    public SeatStatus getStatus() {
        return status;
    }
    
    public void setStatus(SeatStatus status) {
        this.status = status;
    }
    
    @Override
    public boolean equals(Object obj) {
        if (this == obj) return true;
        if (obj == null || getClass() != obj.getClass()) return false;
        Seat seat = (Seat) obj;
        return Objects.equals(seatId, seat.seatId);
    }
    
    @Override
    public int hashCode() {
        return Objects.hash(seatId);
    }
    
    @Override
    public String toString() {
        return "Seat{" +
                "seatId='" + seatId + '\'' +
                ", row=" + row +
                ", column=" + column +
                ", hallId='" + hallId + '\'' +
                ", available=" + available +
                ", status=" + status +
                '}';
    }
} 